using System;

using SBPweb.Data;

namespace SBPweb.PROvibe.Resources.Entities
{
	public class Role: Entity, IRole
	{

		#region Private fields

		private const string FIELDNAME_Id = "Id";
		private const string FIELDNAME_Name = "Name";

		#endregion

		#region Constructor logic

		static Role()
		{
			RegisterEntityTypeToColumns(typeof(Role));
		}

		public Role()
            : base(null)
        {
		}

        public Role(Role entity)
            : base(entity)
        {
        }

		#endregion

		#region Public property accessors

		public virtual int Id
		{
			get
			{
				return GetValue<Int32>(FIELDNAME_Id);
			}
			set
			{
				SetValue<Int32>(FIELDNAME_Id, value);
			}
		}

		public virtual string Name
		{
			get
			{
				return GetValue<String>(FIELDNAME_Name);
			}
			set
			{
				SetValue<String>(FIELDNAME_Name, value);
			}
		}

		#endregion

		#region Overridden methods

		public override object Clone()
		{
			Role role = new Role();

			role.Id = this.Id;
			role.Name = this.Name;

			return role;
		}

        public int CompareTo(IEntity other)
        {
            IRole o = other as IRole;
            if (o == null)
            {
                return 0;
            }
            return this.Id.CompareTo(o.Id);
        }

        public bool Equals(IEntity other)
        {
            IRole o = other as IRole;
            if (o == null)
            {
                return false;
            }
            return this.Id.Equals(o.Id);
        }

		#endregion

	}
}
